Consume HANA Cloud data from python
372d521b13cd4f34fd84c0093a981224.png

The goal is to shows a way to consume SAP HANA Cloud data from a python session executed from my laptop.

The steps I am going to perform are:

  1. Generate a test data set in SAP HANA Cloud and configure the HANA instance
  2. Download HANA client for python
  3. Create a connection from python

1- Generate a data set in SAP HANA Cloud and configure the HANA instance

First i access to my instance in SAP HANA Cloud, using SAP HANA Database Explorer, and launch a script in order to generate test data. The script generates HOTEL scheme and all tables that we are going to fill in (Hotel, customer, city, reservation)

hana_from_python_1.png

I see all generated data from reservation table

hana_from_python_2.png

I configure my HANA instance to allow access from all IP addresses

hana_from_python_3.png hana_from_python_4.png


2- Download HANA client for python

In our laptop,  we download a package (hdbcli) that includes the HANA client and check the version. In my case, using  anaconda prompt:

hana_from_python_5.png

3- Create a connection from Python

I open a Spyder session and test the connection with SAP HANA cloud using "hdcli".

hana_from_python_6.png

The conection parameters for a trial SAP HANA Cloud account are:

HANA_address = 'acXXXX.hana.trial-eu10.hanacloud.ondemand.com'

HANA_port = '443'

HANA_user = 'DBADMIN'

HANA_password = 'XXXX'

I reconnect again and execute a SQL script in order to check received data from reservation table... and voilà!

hana_from_python_7

After connecting to SAP HANA cloud and importing data, any kind of machine learning techniques could be used in Spyder (or in any other python IDE).


I hope it will be useful for you and thanks for sharing!



Home